package org.smr.ministore.micro;

import java.util.List;

import org.blade.dao.base.BaseMapper;
import org.blade.utils.IdGenUtils;
import org.smr.ministore.dao.GoodsSpecificationMapper;
import org.smr.ministore.entities.GoodsPriceOrgan;
import org.smr.ministore.entities.GoodsSpecification;
import org.smr.ministore.entities.vo.Assign2OrganVO;
import org.smr.ministore.entities.vo.Assign2OrgansVO;
import org.smr.ministore.service.GoodsSpecificationService;
import org.blade.service.base.AbstractService;

import org.blade.utils.Pager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;


@RestController
public class GoodsSpecificationMicroService extends AbstractService<Long,GoodsSpecification> implements GoodsSpecificationService {

	@Resource(name = "goodsSpecificationFacade")
	private GoodsSpecificationService service;

	@Autowired
    public GoodsSpecificationMicroService(GoodsSpecificationMapper mapper) {
        super(mapper);
    }

    @ResponseBody
	@RequestMapping(method = RequestMethod.POST, value = "/GoodsSpecification/batchSave")
	public int batchSave(@RequestBody List<GoodsSpecification> entities) {
        this.batchSaveAttatch(entities);
    	return service.batchSave(entities);
    }

    @ResponseBody
    @RequestMapping(method = RequestMethod.POST, value = "/GoodsSpecification/batchModify")
    public int batchModify(List<GoodsSpecification> entities) {
        this.batchModifyAttatch(entities);
        return service.batchModify(entities);
    }


    @ResponseBody
    @RequestMapping(method = RequestMethod.PUT, value = "/GoodsSpecification/save")
    public int save(@RequestBody GoodsSpecification entity) {
        this.saveAttatch(entity);
    	return service.save(entity);
    }

    @ResponseBody
    @RequestMapping(method = RequestMethod.PATCH, value = "/GoodsSpecification/updateById")
    public int updateById(@RequestBody GoodsSpecification id) {
        this.modifyAttach(id);
   	 	return service.updateById(id);
    }

    @ResponseBody
    @RequestMapping(method = RequestMethod.GET, value = "/GoodsSpecification/queryById/{id}")
    public GoodsSpecification queryById( @PathVariable("id")Long id ) {
    	return (GoodsSpecification) service.queryById(id);
    }

    @ResponseBody
    @RequestMapping(method = RequestMethod.DELETE, value = "/GoodsSpecification/deleteById/{id}")
    public int deleteById( @PathVariable("id")Long id ) {
        return service.deleteById(id);
    }

    @ResponseBody
    @RequestMapping( method = RequestMethod.POST, value = "/GoodsSpecification/paginate/{pageSize}/{pageNum}")
    public Pager<GoodsSpecification> paginate( GoodsSpecification entity, @PathVariable("pageSize")Long pageSize,  @PathVariable("pageNum")Long pageNum ) {
        return this.service.paginate( entity, pageSize, pageNum );
    }


    @Override
    @ResponseBody
    @RequestMapping( method = RequestMethod.POST, value = "/GoodsSpecification/assign2Organs")
    public int assign(@RequestBody Assign2OrgansVO assignee) {
        return service.assign(assignee);
    }

    @Override
    @ResponseBody
    @RequestMapping( method = RequestMethod.DELETE, value = "/GoodsSpecification/deleteByIdLogical")
    public int deleteByIdLogical(Long id) {
        return service.deleteByIdLogical(id);
    }

    @Override
    @ResponseBody
    @RequestMapping( method = RequestMethod.POST, value = "/GoodsSpecification/assign2Organ")
    public int assign(@RequestBody Assign2OrganVO goodsAssign2Organ) {
        return service.assign(goodsAssign2Organ);
    }

    @Override
    @ResponseBody
    @RequestMapping( method = RequestMethod.POST, value = "/GoodsSpecification/queryByPrimaryKey")
    public GoodsSpecification queryByPrimaryKey(@RequestBody GoodsSpecification goodsSpecification) {
        return service.queryByPrimaryKey(goodsSpecification);
    }

    @Override
    public Long getId() {
        return IdGenUtils.getNextLongId();
    }
}
